package cn.cocho.android.mct;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import cn.cocho.android.mc.activity.ActivityUtils;
import cn.cocho.android.mc.activity.AsyncDialog;
import cn.cocho.android.mc.activity.BaseActivity;
import cn.cocho.android.mct.anim.RippleViewTest;
import cn.cocho.android.mct.comp.button.SlipButtonTest;
import cn.cocho.android.mct.comp.button.McButtonTest;
import cn.cocho.android.mct.comp.button.McCheckBoxTest;
import cn.cocho.android.mct.comp.button.McRadioButtonTest;
import cn.cocho.android.mct.comp.button.McRadioTabButtonTest;
import cn.cocho.android.mct.comp.button.McTabButtonTest;
import cn.cocho.android.mct.comp.dialog.McDialogTest;
import cn.cocho.android.mct.comp.edit.EditTextWithClearTest;
import cn.cocho.android.mct.comp.image.ImageLoadViewTest;
import cn.cocho.android.mct.comp.image.ZoomImageViewTest;
import cn.cocho.android.mct.comp.image.gifview.GifViewTest;
import cn.cocho.android.mct.comp.listview.McListViewTest;
import cn.cocho.android.mct.comp.swipe.listview.SwipeListViewDifferentTest;
import cn.cocho.android.mct.comp.swipe.listview.SwipeListViewSimpleTest;
import cn.cocho.android.mct.comp.swipe.refresh.SwipeActivityTest;
import cn.cocho.android.mct.comp.tab.TabTest;
import cn.cocho.android.mct.comp.textview.McDrawableTextViewTest;
import cn.cocho.android.mct.comp.textview.McTextViewTest;
import cn.cocho.android.mct.comp.toast.McToastTest;
import cn.cocho.android.mct.comp.webview.McWebViewTest;

public class MainActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		testGifView(McButtonTest.class, R.id.mc_button_test);
		testGifView(McRadioButtonTest.class, R.id.mc_radio_button_test);
		testGifView(McCheckBoxTest.class, R.id.mc_check_button_test);
		testGifView(McRadioTabButtonTest.class, R.id.mc_radio_tab_button_test);

		testGifView(McDialogTest.class, R.id.mc_dialog_test);
		testGifView(EditTextWithClearTest.class, R.id.edit_text_with_clear_test);
		testGifView(McListViewTest.class, R.id.mc_list_view_test);
		testGifView(TabTest.class, R.id.tab_test);
		testGifView(McToastTest.class, R.id.mc_toast_test);

		testGifView(GifViewTest.class, R.id.gif_view_test);
		testGifView(ZoomImageViewTest.class, R.id.zoom_image_view_test);
		testGifView(McTabButtonTest.class, R.id.mc_tab_btn_yzl);
		testGifView(SlipButtonTest.class, R.id.slip_btn);
		testGifView(ImageLoadViewTest.class, R.id.image_loading_view_test);
		testGifView(McTextViewTest.class, R.id.mc_textview_test);
		testGifView(RippleViewTest.class, R.id.ripple_view_test);
		testGifView(McDrawableTextViewTest.class, R.id.mc_drawable_textview_test);
        testGifView(McWebViewTest.class, R.id.mc_webview_test_btn);
        testGifView(SwipeActivityTest.class, R.id.mc_swipe_test_btn);
        testGifView(SwipeListViewSimpleTest.class, R.id.mc_swipe_list_view_sample_test_btn);
        testGifView(SwipeListViewDifferentTest.class, R.id.mc_swipe_list_view_diffrent_test_btn);


		initData();
	}

	public void initData() {
		new AsyncDialog<Object, Object, Boolean>() {

			@Override
			public Boolean initDatas(Object... params) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
					return false;
				}
				return true;
			}

			@Override
			public void initDatasAfter(Boolean result) {
				if (result == null || result == false) {
					ActivityUtils.showLongMessage("数据加载失败");
				} else {
					ActivityUtils.showLongMessage("数据加载完成");
				}
			}
		};
	}

	public void testGifView(final Class<?> activity, int btnId) {
		Button btn = (Button) findViewById(btnId);
		btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				testComp(activity);
			}
		});

	}

	public void testComp(Class<?> cls) {
		Intent in = new Intent(this, cls);
		startActivity(in);
	}

}
